<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            推广二维码
        </div>
        <div class="header-r aui-pull-right">
        </div>
    </header>

    <div style="height:4rem;"></div>

    <div id="list">
    </div>


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/template" id="template">
    <div class="team-item">
        <img src="{{=it.share_img}}" alt="" style="width: 100%;">
    </div>
</script>
<script type="text/javascript">

    apiready = function(){
        loadData();
    }
    

    function loadData(){
        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        // alert(token);
        // alert(authtoken);
        // alert(userid);
        api.ajax({
            url: webAddress + '/a/sale/Qrcode',
            method: 'post',
            data: {
                values: {
                },
            },
            headers: {
                TOKEN: token,
                authuid: userid,
                authtoken: authtoken,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );

                // api.toast({
                //     msg: ret.message,
                //     duration: 2000,
                //     location: 'bottom',
                //     global: 'true',
                // });
                templateFun(ret.result);
            } else {
                // alert( JSON.stringify( err ) );
                if (err.body.message) {
                    api.toast({
                        msg: err.body.message,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
                return false;
            }
        });
    }

    // 模板赋值函数
    function templateFun(data){
        if (data) {
          var template = $api.byId('template');
          var dotFn = doT.template(template.innerHTML);
          var html = dotFn(data);
          var list = $api.byId('list');
          $api.html(list, html);
      }else{

          var list = $api.byId('list');
          var html = '<h2 style="padding:1rem; text-align:center; color:#999; font-size:1rem;">暂无内容</h2>';
          list.innerHTML = html;
      }
  }

  function withdrawdetails(){
    var delay = 0;
    if(api.systemType != 'ios'){
        delay = 300;
    }
    api.openWin({
        name: 'withdrawdetails',
        url: './distribution-withdraw-details.html',
        bounces:false,
        delay: delay,
        slidBackEnabled:true,
        vScrollBarEnabled:false,
        progress:{
            type:"page"
        }
    });
}

function closeWin(){
    api.closeWin({
    });
}
</script>
</html>